package com.koron.order.defectDemotion.bean.po;

import com.koron.order.common.bean.base.ButtonCode;
import com.koron.order.common.bean.base.ButtonUserType;
import com.koron.order.common.bean.base.JurisdictionUserType;

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName DefectDemotionStatus
 * @description
 * @Author zhouj
 * @Date 2022/2/9 11:59
 */
public enum DefectDemotionStatus implements Comparator<DefectDemotionStatus> {

    DRAFT("DRAFT", "草稿", 1),
    WAIT_REVIEW("WAIT_REVIEW", "待审批", 2),
    REVIEWED("REVIEWED", "已审批", 3),
    DEPRECATED("DEPRECATED", "已废弃", 10);

    private String status;
    private String desc;
    private int sort;

    DefectDemotionStatus(String var1, String var2, int sort) {
        this.status = var1;
        this.desc = var2;
        this.sort = sort;
    }

    public static Map<String, List<String>> getPageButtonCode(String status) {
        switch (status) {
            case "DRAFT":
                Map<String, List<String>> draft_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(draft_cond, ButtonCode.save, JurisdictionUserType.creater, JurisdictionUserType.createOrg);
                ButtonUserType.put(draft_cond, ButtonCode.submit, JurisdictionUserType.creater, JurisdictionUserType.createOrg);
                ButtonUserType.put(draft_cond, ButtonCode.delete, JurisdictionUserType.creater, JurisdictionUserType.createOrg);
                return draft_cond;
            default:
                return new HashMap<>();
        }
    }

    public String getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }

    public int getSort() {
        return sort;
    }

    public static DefectDemotionStatus getDefectDemotionStatus(String status) {

        switch (status) {
            case "DRAFT":
                return DRAFT;
            case "WAIT_REVIEW":
                return WAIT_REVIEW;
            case "REVIEWED":
                return REVIEWED;
            case "DEPRECATED":
                return DEPRECATED;
        }
        return null;
    }


    @Override
    public int compare(DefectDemotionStatus o1, DefectDemotionStatus o2) {
        return o1.getSort() - o2.getSort();
    }

}
